package com.ra.landlord;

import java.math.BigDecimal;
import java.sql.Timestamp;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;

import com.googlecode.cswish.annotation.cm;
import com.ra.order.rental.RentalOrder;

/**
 * 待转账租金订单记录
 * 
 * @author shen.kang Date: 2015-8-8
 *
 */
@Entity
public class TransferRentalRecord {
	
	// 待转账
	@cm("待转账")
	public static final int TRANSFER_STATE_DOING = 0;
	
	// 转账成功
	@cm("转账成功")
	public static final int TRANSFER_STATE_SUCCESS = 1;
	
	// 转账失败
	@cm("转账失败")
	public static final int TRANSFER_STATE_FAILURE = 2;
	
	@cm("已合并")
	public static final int TRANSFER_STATE_MERGE = 3;
	
	// 中国银行
	@cm("中国银行")
	public static final String BANKCARD_TYPE_BOC = BankCard.ISSUING_BOC;
	
	// 中国工商银行
	@cm("中国工商银行")
	public static final String BANKCARD_TYPE_ICBC = BankCard.ISSUING_ICBC;
	
	// 中国建设银行
	@cm("中国建设银行")
	public static final String BANKCARD_TYPE_CCB = BankCard.ISSUING_CCB;
	
	// 中国农业银行
	@cm("中国农业银行")
	public static final String BANKCARD_TYPE_ABC = BankCard.ISSUING_ABC;
	
	// 招商银行
	@cm("招商银行")
	public static final String BANKCARD_TYPE_CMB = BankCard.ISSUING_CMB;
	
	// 平安银行
	@cm("平安银行")
	public static final String BANKCARD_TYPE_PAB = BankCard.ISSUING_PAB;
	
	// 转账ID
	private Integer Id;
	
	// 转账流水号
	@cm("转账流水号")
	private String transferNo;
	
	// 转账当天日期（20150808）
	@cm("转账当天日期")
	private String transferDate;
	
	// 转账总金额
	@cm("总金额")
	private BigDecimal transferFee;
	
	// 订单数
	@cm("订单数")
	private Integer orderNum;
	
	// 租金订单
	private List<RentalOrder> rentalOrders;
	
	// 转账记录创建时间
	@cm("创建时间")
	private Timestamp createTime;
	
	// 房东
	private LandlordUser landlordUser;
	
	// 转账状态
	@cm("转账状态")
	private Integer transferState;
	
	@ManyToOne(cascade = CascadeType.REFRESH, fetch = FetchType.LAZY)
	@JoinColumn(name = "landlordUserId")
	public LandlordUser getLandlordUser() {
		return landlordUser;
	}

	public void setLandlordUser(LandlordUser landlordUser) {
		this.landlordUser = landlordUser;
	}

	public Integer getTransferState() {
		return transferState;
	}

	public void setTransferState(Integer transferState) {
		this.transferState = transferState;
	}

	public String getTransferNo() {
		return transferNo;
	}

	public void setTransferNo(String transferNo) {
		this.transferNo = transferNo;
	}

	public String getTransferDate() {
		return transferDate;
	}

	public void setTransferDate(String transferDate) {
		this.transferDate = transferDate;
	}

	public BigDecimal getTransferFee() {
		return transferFee;
	}

	public void setTransferFee(BigDecimal transferFee) {
		this.transferFee = transferFee;
	}

	public Integer getOrderNum() {
		return orderNum;
	}

	public void setOrderNum(Integer orderNum) {
		this.orderNum = orderNum;
	}

	public Timestamp getCreateTime() {
		return createTime;
	}

	public void setCreateTime(Timestamp createTime) {
		this.createTime = createTime;
	}

	@Id
	@GeneratedValue
	public Integer getId() {
		return Id;
	}

	public void setId(Integer id) {
		Id = id;
	}

	@OneToMany(targetEntity=RentalOrder.class, cascade = CascadeType.MERGE, fetch = FetchType.LAZY, mappedBy="transferRentalRecord")
	public List<RentalOrder> getRentalOrders() {
		return rentalOrders;
	}

	public void setRentalOrders(List<RentalOrder> rentalOrders) {
		this.rentalOrders = rentalOrders;
	}

}
